unit ListOfBitArrayTest;

interface
uses Classes, SysUtils, AVTypes, Generics.Collections, Windows, AVUtils;

procedure TestListOfBitArray;

implementation

procedure TestListOfBitArray;
const testCount: integer = 10000000;
var i: integer;
    listBit: TList<TBitarray>;
    listInt: TList<integer>;
    lastTick: DWord;
    b: boolean;
begin
  listBit := TList<TBitArray>.Create;
  listInt := TList<integer>.Create;
  try
    lastTick := GetTickCount;
    listBit.Count := testCount;
    WriteLn('BitList fill = ' + IntToStr(GetTickCount - lastTick));

    lastTick := GetTickCount;
    listInt.Count := testCount;
    WriteLn('IntList fill = ' + IntToStr(GetTickCount - lastTick));

    lastTick := GetTickCount;
    for i := 0 to testCount - 1 do
    begin
      listBit[i].Bit[5] := true;
      b := listBit[i].Bit[7];
    end;
    WriteLn('BitList Test = ' + IntToStr(GetTickCount - lastTick));

    lastTick := GetTickCount;
    for i := 0 to testCount - 1 do
    begin
      listBit.List[i].Bit[5] := true;
      b := listBit.List[i].Bit[7];
    end;
    WriteLn('BitList2 Test = ' + IntToStr(GetTickCount - lastTick));

    lastTick := GetTickCount;
    for i := 0 to testCount - 1 do
    begin
      SetBit(listInt.List[i], 5, true);
      b := GetBit(listInt.List[i], 5);
      if not b then raise Exception.Create('Error Message');
      SetBit(listInt.List[i], 7, false);
      b := GetBit(listInt.List[i], 7);
      if b then raise Exception.Create('Error Message');
    end;
    WriteLn('IntList Test = ' + IntToStr(GetTickCount - lastTick));

  finally
    listBit.Free;
    listInt.Free;
  end;
end;


end.
